package main

import (
	"flag"
	"log"

	"github.com/Kindling-project/chaos-backend/configs"
	"github.com/Kindling-project/chaos-backend/internal/app"
)

func main() {
	httpPort := flag.String("port", ":8080", "port to listen on, default to :8080")

	authType := flag.String("authType", "kubeConfig", "AuthType describes the type of authentication to use for the K8s API, support 'kubeConfig' or 'serviceAccount'. ")
	kubeConfigPath := flag.String("kubeConfig", "~/.kube/config", "kubeConfig describe the filePath to your kubeConfig,only used when authType is 'kubeConfig'")

	chaosTemplateFilePath := flag.String("chaos_template_file_path", "config/chaos_template.yaml", "set chaos_template config file path")
	unstructuredChaosFilePath := flag.String("unstructured_chaos_file_path", "config/unstructured_chaos.gotmpl", "set unstructured chaos_template file path")
	skywalkingUIAddr := flag.String("skywalkingUIAddr", "http://skywalking.train-ticket:12800/graphql", "skywalkingUIAddr describe the address of your skywalking UI")
	prometheusUIAddr := flag.String("prometheusUIAddr", "http://prometheus-k8s.monitoring:9090/", "prometheusUIAddr describe the address of your prometheus UI")
	trainTicketUIAddr := flag.String("trainTicketUIAddr", "http://ts-gateway-service.train-ticket:18888", "trainTicketUIAddr describe the address of your train-ticket UI")
	metricSource := flag.String("metricSource", "skywalking", "use skywalking or prometheus to show request latency and cpm metric, default skywalking")
	enableDebug := flag.Bool("debug", false, "enable debug log")
	flag.Parse()

	app := app.SetupApplication(
		configs.AuthType(*authType),
		*kubeConfigPath,
		*skywalkingUIAddr,
		*prometheusUIAddr,
		*trainTicketUIAddr,
		*chaosTemplateFilePath,
		*unstructuredChaosFilePath,
		*metricSource,
		*enableDebug,
	)

	log.Fatalln(app.Run(*httpPort))
}
